package com.wangzhen.codebase;

public class InterruptedDemo {
    public static void main(String[] args) throws InterruptedException {
        final Thread t1 = new Thread(() -> {

            Thread thread = Thread.currentThread();
            while (true) {
                if (thread.isInterrupted()) {
                    break;
                }
                try {
                    System.out.println("111111");
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    System.out.println("进入异常了");
                    e.printStackTrace();
                }
            }
        });


        t1.start();
        Thread.sleep(1000);
        t1.interrupt();

        while (true) {
            Thread.sleep(1000);
        }
    }
}
